package top.hcode.hoj.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import top.hcode.hoj.pojo.entity.problem.Tag;
import top.hcode.hoj.pojo.entity.problem.TagRel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author orangej
 * @since 2024/12/24
 */
@Mapper
@Repository
public interface TagRelMapper extends BaseMapper<TagRel> {

    @Select("select * from tag where id in (select tag_id from tag_rel where target_id = #{targetId} and target_type = #{targetType})")
    public List<Tag> getTagsByTarget(@Param("targetId") Long targetId, @Param("targetType") String targetType);
    
    @Select("select * from tag where id in (select tag_id from tag_rel where target_id in (#{targetIds}) and target_type = #{targetType})")
    public List<Tag> getTagsByTargets(@Param("targetIds") List<Long> targetIds, @Param("targetType") String targetType);

    
}
